<template>
  <div>
    <button @click="getStudents">点我获取学生信息</button>
    <br />
    <br />
    <button @click="getCars">点我获取汽车信息</button>
    <br />
    <br />
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'App',
  methods: {
    getStudents() {
      axios.get('http://localhost:8080/api/students').then(
        response => {
          console.log('学生信息是:', response.data);
        },
        error => {
          console.log('错误信息是:', error.message);
        }
      );
    },
    getCars() {
      axios.get('http://localhost:8080/demo/cars').then(
        response => {
          console.log('汽车信息是:', response.data);
        },
        error => {
          console.log('错误信息是:', error.message);
        }
      );
    },
  },
};
</script>
